<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends MX_Controller {


	function __construct(){

		//$this->load->model('content/content_model');
		$this->load->model('search/search_model');
		$this->load->library(array('pagination'));
		$this->load->library('session');
		$this->load->helper(array('form', 'url'));
		$this->load->library('currency/currency');	
	}
	
	function lists(){
		
		$data['match'] = '';
		if(isset($_POST['search'])){
			$data['match'] = $this->input->post('search');
			$this->session->set_userdata('sess_search', $data['match']);
		}else{
			$data['match'] = $this->session->userdata('sess_search');
		}
		
		$offset = $this->uri->segment(3);
		$limit = '5';
		if(!$offset){
			$page = 0;
		}else{
			$page = $offset; 	
		}
		
		
		$data['search'] = $this->search_model->get_search($data['match'], $page, $limit);
	    $data['count'] = count($this->search_model->get_search($data['match'], 0, 0));
		
		$config_pagination['base_url']    = site_url('search/lists/');
		$config_pagination['total_rows']  = count($this->search_model->get_search($data['match'], 0, 0));
		$config_pagination['per_page']    = $limit;
		$config_pagination['uri_segment'] = 3;
		$config_pagination['num_links']   = 4;

		//pagination style
		$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
		$config_pagination['full_tag_close'] = '</ul></div>';

		$config_pagination['first_link'] = 'First';
		$config_pagination['first_tag_open']  = '<li>';
		$config_pagination['first_tag_close'] = '</li>';

		$config_pagination['last_link'] = 'Last';
		$config_pagination['last_tag_open']  = '<li>';
		$config_pagination['last_tag_close'] = '</li>';

		$config_pagination['next_link'] = '&gt;';
		$config_pagination['next_tag_open']  = '<li>';
		$config_pagination['next_tag_close'] = '</li>';

		$config_pagination['prev_link'] = '&lt;';
		$config_pagination['prev_tag_open'] = '<li>';
		$config_pagination['prev_tag_close'] = '</li>';

		$config_pagination['cur_tag_open'] = '<li><span class="current">';
		$config_pagination['cur_tag_close'] = '</span></li>';

		$config_pagination['num_tag_open'] = '<li>';
		$config_pagination['num_tag_close'] = '</li>';

		$this->pagination->initialize($config_pagination); 
		$data['pagination'] = $this->pagination->create_links();
		
		$this->load->view('search/search',$data);
	}
	
	function grid(){
		
		$data['match'] = '';
		if(isset($_POST['search'])){
			$data['match'] = $this->input->post('search');
			$this->session->set_userdata('sess_search', $data['match']);
		}else{
			$data['match'] = $this->session->userdata('sess_search');
		}
		
		$offset = $this->uri->segment(3);
		$limit = '12';
		if(!$offset){
			$page = 0;
		}else{
			$page = $offset; 	
		}
		
		
		$data['search'] = $this->search_model->get_search($data['match'], $page, $limit);
	    $data['count'] = count($this->search_model->get_search($data['match'], 0, 0));
		
		$config_pagination['base_url']    = site_url('search/grid/');
		$config_pagination['total_rows']  = count($this->search_model->get_search($data['match'], 0, 0));
		$config_pagination['per_page']    = $limit;
		$config_pagination['uri_segment'] = 3;
		$config_pagination['num_links']   = 4;

		//pagination style
		$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
		$config_pagination['full_tag_close'] = '</ul></div>';

		$config_pagination['first_link'] = 'First';
		$config_pagination['first_tag_open']  = '<li>';
		$config_pagination['first_tag_close'] = '</li>';

		$config_pagination['last_link'] = 'Last';
		$config_pagination['last_tag_open']  = '<li>';
		$config_pagination['last_tag_close'] = '</li>';

		$config_pagination['next_link'] = '&gt;';
		$config_pagination['next_tag_open']  = '<li>';
		$config_pagination['next_tag_close'] = '</li>';

		$config_pagination['prev_link'] = '&lt;';
		$config_pagination['prev_tag_open'] = '<li>';
		$config_pagination['prev_tag_close'] = '</li>';

		$config_pagination['cur_tag_open'] = '<li><span class="current">';
		$config_pagination['cur_tag_close'] = '</span></li>';

		$config_pagination['num_tag_open'] = '<li>';
		$config_pagination['num_tag_close'] = '</li>';

		$this->pagination->initialize($config_pagination); 
		$data['pagination'] = $this->pagination->create_links();
		
		$this->load->view('search/search_grid',$data);
	}
	
	function lists_low(){
		
		$data['match'] = '';
		if(isset($_POST['search'])){
			$data['match'] = $this->input->post('search');
			$this->session->set_userdata('sess_search', $data['match']);
		}else{
			$data['match'] = $this->session->userdata('sess_search');
		}
		
		$offset = $this->uri->segment(3);
		$limit = '5';
		if(!$offset){
			$page = 0;
		}else{
			$page = $offset; 	
		}
		
		
		$data['search'] = $this->search_model->get_search_low($data['match'], $page, $limit);
	    $data['count'] = count($this->search_model->get_search_low($data['match'], 0, 0));
		
		$config_pagination['base_url']    = site_url('search/lists_low/');
		$config_pagination['total_rows']  = count($this->search_model->get_search_low($data['match'], 0, 0));
		$config_pagination['per_page']    = $limit;
		$config_pagination['uri_segment'] = 3;
		$config_pagination['num_links']   = 4;

		//pagination style
		$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
		$config_pagination['full_tag_close'] = '</ul></div>';

		$config_pagination['first_link'] = 'First';
		$config_pagination['first_tag_open']  = '<li>';
		$config_pagination['first_tag_close'] = '</li>';

		$config_pagination['last_link'] = 'Last';
		$config_pagination['last_tag_open']  = '<li>';
		$config_pagination['last_tag_close'] = '</li>';

		$config_pagination['next_link'] = '&gt;';
		$config_pagination['next_tag_open']  = '<li>';
		$config_pagination['next_tag_close'] = '</li>';

		$config_pagination['prev_link'] = '&lt;';
		$config_pagination['prev_tag_open'] = '<li>';
		$config_pagination['prev_tag_close'] = '</li>';

		$config_pagination['cur_tag_open'] = '<li><span class="current">';
		$config_pagination['cur_tag_close'] = '</span></li>';

		$config_pagination['num_tag_open'] = '<li>';
		$config_pagination['num_tag_close'] = '</li>';

		$this->pagination->initialize($config_pagination); 
		$data['pagination'] = $this->pagination->create_links();
		
		$this->load->view('search/search_low',$data);
	}
	
	function grid_low(){
		
		$data['match'] = '';
		if(isset($_POST['search'])){
			$data['match'] = $this->input->post('search');
			$this->session->set_userdata('sess_search', $data['match']);
		}else{
			$data['match'] = $this->session->userdata('sess_search');
		}
		
		$offset = $this->uri->segment(3);
		$limit = '12';
		if(!$offset){
			$page = 0;
		}else{
			$page = $offset; 	
		}
		
		
		$data['search'] = $this->search_model->get_search_low($data['match'], $page, $limit);
	    $data['count'] = count($this->search_model->get_search_low($data['match'], 0, 0));
		
		$config_pagination['base_url']    = site_url('search/grid_low/');
		$config_pagination['total_rows']  = count($this->search_model->get_search_low($data['match'], 0, 0));
		$config_pagination['per_page']    = $limit;
		$config_pagination['uri_segment'] = 3;
		$config_pagination['num_links']   = 4;

		//pagination style
		$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
		$config_pagination['full_tag_close'] = '</ul></div>';

		$config_pagination['first_link'] = 'First';
		$config_pagination['first_tag_open']  = '<li>';
		$config_pagination['first_tag_close'] = '</li>';

		$config_pagination['last_link'] = 'Last';
		$config_pagination['last_tag_open']  = '<li>';
		$config_pagination['last_tag_close'] = '</li>';

		$config_pagination['next_link'] = '&gt;';
		$config_pagination['next_tag_open']  = '<li>';
		$config_pagination['next_tag_close'] = '</li>';

		$config_pagination['prev_link'] = '&lt;';
		$config_pagination['prev_tag_open'] = '<li>';
		$config_pagination['prev_tag_close'] = '</li>';

		$config_pagination['cur_tag_open'] = '<li><span class="current">';
		$config_pagination['cur_tag_close'] = '</span></li>';

		$config_pagination['num_tag_open'] = '<li>';
		$config_pagination['num_tag_close'] = '</li>';

		$this->pagination->initialize($config_pagination); 
		$data['pagination'] = $this->pagination->create_links();
		
		$this->load->view('search/search_grid_low',$data);
	}
	
	function lists_high(){
		
		$data['match'] = '';
		if(isset($_POST['search'])){
			$data['match'] = $this->input->post('search');
			$this->session->set_userdata('sess_search', $data['match']);
		}else{
			$data['match'] = $this->session->userdata('sess_search');
		}
		
		$offset = $this->uri->segment(3);
		$limit = '5';
		if(!$offset){
			$page = 0;
		}else{
			$page = $offset; 	
		}
		
		
		$data['search'] = $this->search_model->get_search_high($data['match'], $page, $limit);
	    $data['count'] = count($this->search_model->get_search_high($data['match'], 0, 0));
		
		$config_pagination['base_url']    = site_url('search/lists_high/');
		$config_pagination['total_rows']  = count($this->search_model->get_search_high($data['match'], 0, 0));
		$config_pagination['per_page']    = $limit;
		$config_pagination['uri_segment'] = 3;
		$config_pagination['num_links']   = 4;

		//pagination style
		$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
		$config_pagination['full_tag_close'] = '</ul></div>';

		$config_pagination['first_link'] = 'First';
		$config_pagination['first_tag_open']  = '<li>';
		$config_pagination['first_tag_close'] = '</li>';

		$config_pagination['last_link'] = 'Last';
		$config_pagination['last_tag_open']  = '<li>';
		$config_pagination['last_tag_close'] = '</li>';

		$config_pagination['next_link'] = '&gt;';
		$config_pagination['next_tag_open']  = '<li>';
		$config_pagination['next_tag_close'] = '</li>';

		$config_pagination['prev_link'] = '&lt;';
		$config_pagination['prev_tag_open'] = '<li>';
		$config_pagination['prev_tag_close'] = '</li>';

		$config_pagination['cur_tag_open'] = '<li><span class="current">';
		$config_pagination['cur_tag_close'] = '</span></li>';

		$config_pagination['num_tag_open'] = '<li>';
		$config_pagination['num_tag_close'] = '</li>';

		$this->pagination->initialize($config_pagination); 
		$data['pagination'] = $this->pagination->create_links();
		
		$this->load->view('search/search_high',$data);
	}
	
	function grid_high(){
		
		$data['match'] = '';
		if(isset($_POST['search'])){
			$data['match'] = $this->input->post('search');
			$this->session->set_userdata('sess_search', $data['match']);
		}else{
			$data['match'] = $this->session->userdata('sess_search');
		}
		
		$offset = $this->uri->segment(3);
		$limit = '12';
		if(!$offset){
			$page = 0;
		}else{
			$page = $offset; 	
		}
		
		
		$data['search'] = $this->search_model->get_search_high($data['match'], $page, $limit);
	    $data['count'] = count($this->search_model->get_search_high($data['match'], 0, 0));
		
		$config_pagination['base_url']    = site_url('search/grid_high/');
		$config_pagination['total_rows']  = count($this->search_model->get_search_high($data['match'], 0, 0));
		$config_pagination['per_page']    = $limit;
		$config_pagination['uri_segment'] = 3;
		$config_pagination['num_links']   = 4;

		//pagination style
		$config_pagination['full_tag_open'] = '<div class="pagination"><ul>';
		$config_pagination['full_tag_close'] = '</ul></div>';

		$config_pagination['first_link'] = 'First';
		$config_pagination['first_tag_open']  = '<li>';
		$config_pagination['first_tag_close'] = '</li>';

		$config_pagination['last_link'] = 'Last';
		$config_pagination['last_tag_open']  = '<li>';
		$config_pagination['last_tag_close'] = '</li>';

		$config_pagination['next_link'] = '&gt;';
		$config_pagination['next_tag_open']  = '<li>';
		$config_pagination['next_tag_close'] = '</li>';

		$config_pagination['prev_link'] = '&lt;';
		$config_pagination['prev_tag_open'] = '<li>';
		$config_pagination['prev_tag_close'] = '</li>';

		$config_pagination['cur_tag_open'] = '<li><span class="current">';
		$config_pagination['cur_tag_close'] = '</span></li>';

		$config_pagination['num_tag_open'] = '<li>';
		$config_pagination['num_tag_close'] = '</li>';

		$this->pagination->initialize($config_pagination); 
		$data['pagination'] = $this->pagination->create_links();
		
		$this->load->view('search/search_grid_high',$data);
	}
	
}

/* End of file common.php */